package com.qianfeng.zw.meilishuo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.qianfeng.zw.meilishuo.R;
import com.qianfeng.zw.meilishuo.bean.FashRecom;
import com.qianfeng.zw.meilishuo.utils.Utility;

import java.util.List;


/**
 * @作 用:
 * @创 建 人: zhangwei
 * @日 期: 15/4/1 22:22
 * @修 改 人:
 * @日 期:
 */
public class FashRecommAdapter extends BaseAdapter {
    private boolean isShowAll = false;
    private List<FashRecom> list;
    private Context context;

    public FashRecommAdapter(List<FashRecom> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        FashRecom fashRemm = list.get(position);
        ViewHolder vh = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.itemview_fash_recomm_layout, parent, false);
            vh = new ViewHolder(convertView);
            convertView.setTag(vh);
        } else {
            vh = (ViewHolder) convertView.getTag();
        }
        ImageLoader.getInstance().displayImage(fashRemm.getImage_url(), vh.img);
        return convertView;
    }

    private class ViewHolder {
        private ImageView img;
        public ViewHolder(View view) {
            img = (ImageView) view.findViewById(R.id.itemview_fash_recomm_img);
        }
    }

    public void setIsShowAllView(List<FashRecom> list, GridView gridView) {
        this.list = list;
        this.notifyDataSetChanged();
        Utility.setGridviewHeightBasedOnChildren(gridView);
    }

}
